package io.github.jast90.internship.service;

import io.github.jast90.internship.entity.InternshipProgramEvaluation;
import io.github.jast90.internship.mapper.InternshipProgramEvaluationMapper;
import io.github.jast90.internship.util.SessionUtil;
import io.github.jast90.mybatis.pagination.domain.Page;
import io.github.jast90.mybatis.pagination.domain.PageRequest;
import io.github.jast90.web.common.result.CommonResult;
import io.github.jast90.web.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by jast90 on 2021/3/8
 */
@Service
public class InternshipProgramEvaluationService extends BaseService<InternshipProgramEvaluationMapper, InternshipProgramEvaluation> {
    @Autowired
    private SessionUtil sessionUtil;

    @Override
    public CommonResult<Page<InternshipProgramEvaluation>> queryPage(PageRequest pageRequest, InternshipProgramEvaluation entity) {
        if(sessionUtil.student()){
            entity.setStudentId(sessionUtil.getUid());
        }
        if(sessionUtil.teacher()){
            entity.setTeacherId(sessionUtil.getUid());
        }
        return super.queryPage(pageRequest, entity);
    }
}
